package com.quanquan.store.controller;

import com.quanquan.store.request.CouponTypeRequest;
import com.quanquan.store.service.CouponTypeService;
import enums.ResCodeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import web.response.ResultBody;

import java.util.List;

/**
 * @ClassName:CouponTypeController
 * @Description:TODO
 * @Author:xiongjunbao
 * @Date:2019/4/26 17:12
 * @Version 1.0
 */
@RestController
@RequestMapping("/coupon_type")
public class CouponTypeController {

    private final CouponTypeService couponTypeService;

    @Autowired
    public CouponTypeController(CouponTypeService couponTypeService) {
        this.couponTypeService = couponTypeService;
    }


    /**
     * 查找优惠券类型列表
     *
     * @param request
     * @return
     */
    @PostMapping("/query_coupon_type")
    public ResultBody queryCouponType(@RequestBody CouponTypeRequest request) {
        List<Object> objectList = couponTypeService.findCouponType();
        if (objectList.size()<=0){
            return new ResultBody(ResCodeEnum.NO_DATA.getCode(), "暂无数据");
        }
        return new ResultBody(ResCodeEnum.SUCCESS.getCode(), "SUCCESS");
    }

    /**
     * 查找优惠券价值类型列表
     *
     * @param request
     * @return
     */
    @PostMapping("/query_coupon_value_type")
    public ResultBody queryCouponValueType(@RequestBody CouponTypeRequest request) {
        List<Object> objectList = couponTypeService.findCouponValueType();
        if (objectList.size()<=0){
            return new ResultBody(ResCodeEnum.NO_DATA.getCode(), "暂无数据");
        }
        return new ResultBody(ResCodeEnum.SUCCESS.getCode(), "SUCCESS");
    }


}
